// 本模块用来调用首页接口与相关逻辑处理
import axios from 'axios';
import QS from 'qs';

export default {
	userCenterInfo(data) {
		return axios({
			url: 'api/user-center',
			method: 'POST',
			data: {},
		})
	},
	userInfoUpdate(data) {
		let nowData = {
			name: data.name,
			phone: data.phone,
			unit_position: data.unit_position,
			email: data.email,
			face_to_face: data.face_to_face,
			detailed_address: data.detailed_address,
		}
		return axios({
			url: 'api/personal-center-update',
			method: 'post',
			data: QS.stringify(nowData),

		})
	},
	changePassword(data) {
		let nowData = {
			old_password: data.old_password,
			new_password: data.new_password,
			new_passwords: data.new_passwords,
		}
		return axios({
			url: 'api/change-pwd',
			method: 'post',
			data: QS.stringify(nowData),
		})
	},
	// 修改手机号
	changePhone(data) {
		let nowData = {
			password: data.password,
			new_phone: data.new_phone,
			phone_code: data.phone_code,
		}
		return axios({
			url: 'api/change-phone',
			method: 'post',
			data: QS.stringify(nowData),
		})
	},

	// 上传头像
	uploadImg(data) {
		return axios({
			url: 'api/upload-img',
			method: 'post',
			data: {
				file: data.file
			},
			headers: {
				'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq',
			}
		})
	},
	// 公司性质
	companyNature() {
		return axios({
			url: 'api/company-nature',
			method: 'get',
			params: {}
		})
	},
	// 赛题方向
	direction() {
		return axios({
			url: 'api/direction',
			method: 'get',
			params: {}
		})
	},
	// 公司信息保存 
	companySave(data) {
		let nowData = {
			nature_id: data.nature_id,
			title: data.title,
			sub_title: data.sub_title,
			is_listed: data.is_listed,
			is_finance: data.is_finance,
			patent_count: data.patent_count,
			work_address: data.work_address,
			province: data.province,
			city: data.city,
			area: data.area,
		}
		return axios({
			url: 'api/company-save',
			method: 'post',
			data: QS.stringify(nowData),
		})
	},
	// 公司信息详情
	companyInfo() {
		return axios({
			url: 'api/company-info',
			method: 'get',
			params: {}
		})
	},
	// 团队信息保存 
	teamSave(data) {
		let nowData = {
			title: data.title,
			data: data.data,
			delete_ids: data.delete_ids,
		}
		return axios({
			url: 'api/team-save',
			method: 'post',
			data: QS.stringify(nowData),
		})
	},
	// 团队信息详情
	teamInfo() {
		return axios({
			url: 'api/team-info',
			method: 'get',
			params: {}
		})
	},
	// 项目信息保存 
	projectSave(data) {
		let nowData = {
			direction_id: data.direction_id,
			app_count: data.app_count,
			title: data.title,
			is_patent: data.is_patent,
			is_online_events: data.is_online_events,
			content: data.content,
			logo_url: data.logo_url,
			enroll_form_url: data.enroll_form_url,
			pic_url: data.pic_url,
			ppt_url: data.ppt_url,
			video_url: data.video_url,
		}
		return axios({
			url: 'api/project-save',
			method: 'post',
			data: QS.stringify(nowData),
		})
	},
	// 项目信息详情
	projectInfo() {
		return axios({
			url: 'api/project-info',
			method: 'get',
			params: {}
		})
	},
	// 上传文件
	uploadFile(data) {
		return axios({
			url: 'api/upload-file',
			method: 'post',
			data: {
				file: data.file,
				type: data.type//1:企业logo; 2:报名表; 3:项目介绍; 4:项目图片; 5:展示视频; 6:其他
			},
			headers: {
				'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq',
			}
		})
	},
}
